#ifndef BFCP_UDP_TRANSPORT_HXX
#define BFCP_UDP_TRANSPORT_HXX

#include "BfcpTransportIf.hxx"
#include "rutil/FdPoll.hxx"

namespace bfcp
{
    class BfcpUdpTransport : public BfcpTransportIf, public resip::FdPollItemIf
    {
    public:
        BfcpUdpTransport(const resip::Data& intfc,
                         int portNum,
                         resip::IpVersion version,
                         resip::Fifo<BfcpTransactionMessage>& rxFifo);
        virtual ~BfcpUdpTransport();

        virtual void setRcvBufLen(int buflen);

        virtual void setPollGrp(resip::FdPollGrp *grp);

        virtual void processPollEvent(resip::FdPollEventMask mask);

        virtual void process();

        //static const int CommonHeaderSize = 12;

    protected:
        void processRxAll();
        typedef std::pair<char*, int> BufferPair;
        int processRxRecv(BufferPair& bufferPair, BfcpNetTuple& sender);
        bool processRxParse(BufferPair& bufferPair, int len, BfcpNetTuple& sender);
        void processTxAll();
        void processTxOne(BfcpSendData *data);
        void updateEvents();

    private:
        bool mInWritable;
        BufferPair mRxBuffer;
    };
}

#endif //#ifndef BFCP_UDP_TRANSPORT_HXX
